﻿#region Imports

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Workflow.Dto;
using Workflow.IService;
using Workflow.IDAO;
using Workflow.Model;

#endregion


namespace Workflow.Service
{
    public class UserManager:IUserManager
    {
        #region Properties

        public IUserDao UserDao { get; set; }

        #endregion


        /// <summary>
        /// 获取用户
        /// </summary>
        /// <param name="userId">用户ID</param>
        /// <returns></returns>
        public User GetUser(long userId)
        {
            return UserDao.Get(userId);
        }

      
		/// <summary>
		/// 所有User取得（分页）
		/// </summary>
		public IList<User> GetUsersByPage(out long count, int pageIndex, int pageSize, UserQueryDto userQueryDto)
		{
			return UserDao.GetUsersByPage(out count, pageIndex, pageSize, userQueryDto);
		}

    	/// <summary>
    	/// save user
    	/// </summary>
    	/// <param name="user"></param>
    	/// <returns></returns>
    	public void SaveOrUpdateUser(User user)
		{
			 UserDao.SaveOrUpdate(user);
		}

		/// <summary>
		/// DeleteUser
		/// </summary>
		/// <param name="userId"></param>
		public void DeleteUser(string userId)
		{
			UserDao.Delete(userId);
		}
		/// <summary>
		/// GetAllUser
		/// </summary>
		public IList<User> GetAllUser()
		{
			return UserDao.LoadAll().ToList();
		}

        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public UserQueryDto UserLogin(long username, string password)
        {
            return UserDao.UserLogin(username, password);
        }
		/// <summary>
		/// 通过权限取得对应的用户
		/// </summary>
		public IList<User> GetUserForRole(int role)
		{
			return UserDao.GetUserForRole(role);
		}
    }
}
